# NOTE: Assertions have been autogenerated by utils/update_mca_test_checks.py
# RUN: llvm-mca -mtriple=x86_64-unknown-unknown -mcpu=haswell --json -instruction-tables < %s | FileCheck %s
# RUN: llvm-mca -mtriple=x86_64-unknown-unknown -mcpu=haswell --json -instruction-tables -o %t.json < %s
# RUN: cat %t.json \
# RUN:  | %python -c 'import json, sys; json.dump(json.loads(sys.stdin.read()), sys.stdout, sort_keys=True, indent=2)' \
# RUN:  | FileCheck %s

# LLVM-MCA-BEGIN foo
add %eax, %eax
# LLVM-MCA-BEGIN bar
add %ebx, %ebx
add %ecx, %ecx
# LLVM-MCA-END bar
add %edx, %edx
# LLVM-MCA-END foo

# CHECK:      {
# CHECK-NEXT:   "CodeRegions": [
# CHECK-NEXT:     {
# CHECK-NEXT:       "InstructionInfoView": {
# CHECK-NEXT:         "InstructionList": [
# CHECK-NEXT:           {
# CHECK-NEXT:             "Instruction": 0,
# CHECK-NEXT:             "Latency": 1,
# CHECK-NEXT:             "NumMicroOpcodes": 1,
# CHECK-NEXT:             "RThroughput": 0.25,
# CHECK-NEXT:             "hasUnmodeledSideEffects": false,
# CHECK-NEXT:             "mayLoad": false,
# CHECK-NEXT:             "mayStore": false
# CHECK-NEXT:           },
# CHECK-NEXT:           {
# CHECK-NEXT:             "Instruction": 1,
# CHECK-NEXT:             "Latency": 1,
# CHECK-NEXT:             "NumMicroOpcodes": 1,
# CHECK-NEXT:             "RThroughput": 0.25,
# CHECK-NEXT:             "hasUnmodeledSideEffects": false,
# CHECK-NEXT:             "mayLoad": false,
# CHECK-NEXT:             "mayStore": false
# CHECK-NEXT:           },
# CHECK-NEXT:           {
# CHECK-NEXT:             "Instruction": 2,
# CHECK-NEXT:             "Latency": 1,
# CHECK-NEXT:             "NumMicroOpcodes": 1,
# CHECK-NEXT:             "RThroughput": 0.25,
# CHECK-NEXT:             "hasUnmodeledSideEffects": false,
# CHECK-NEXT:             "mayLoad": false,
# CHECK-NEXT:             "mayStore": false
# CHECK-NEXT:           },
# CHECK-NEXT:           {
# CHECK-NEXT:             "Instruction": 3,
# CHECK-NEXT:             "Latency": 1,
# CHECK-NEXT:             "NumMicroOpcodes": 1,
# CHECK-NEXT:             "RThroughput": 0.25,
# CHECK-NEXT:             "hasUnmodeledSideEffects": false,
# CHECK-NEXT:             "mayLoad": false,
# CHECK-NEXT:             "mayStore": false
# CHECK-NEXT:           }
# CHECK-NEXT:         ]
# CHECK-NEXT:       },
# CHECK-NEXT:       "Instructions": [
# CHECK-NEXT:         "addl\t%eax, %eax",
# CHECK-NEXT:         "addl\t%ebx, %ebx",
# CHECK-NEXT:         "addl\t%ecx, %ecx",
# CHECK-NEXT:         "addl\t%edx, %edx"
# CHECK-NEXT:       ],
# CHECK-NEXT:       "Name": "foo",
# CHECK-NEXT:       "ResourcePressureView": {
# CHECK-NEXT:         "ResourcePressureInfo": [
# CHECK-NEXT:           {
# CHECK-NEXT:             "InstructionIndex": 0,
# CHECK-NEXT:             "ResourceIndex": 2,
# CHECK-NEXT:             "ResourceUsage": 0.25
# CHECK-NEXT:           },
# CHECK-NEXT:           {
# CHECK-NEXT:             "InstructionIndex": 0,
# CHECK-NEXT:             "ResourceIndex": 3,
# CHECK-NEXT:             "ResourceUsage": 0.25
# CHECK-NEXT:           },
# CHECK-NEXT:           {
# CHECK-NEXT:             "InstructionIndex": 0,
# CHECK-NEXT:             "ResourceIndex": 7,
# CHECK-NEXT:             "ResourceUsage": 0.25
# CHECK-NEXT:           },
# CHECK-NEXT:           {
# CHECK-NEXT:             "InstructionIndex": 0,
# CHECK-NEXT:             "ResourceIndex": 8,
# CHECK-NEXT:             "ResourceUsage": 0.25
# CHECK-NEXT:           },
# CHECK-NEXT:           {
# CHECK-NEXT:             "InstructionIndex": 1,
# CHECK-NEXT:             "ResourceIndex": 2,
# CHECK-NEXT:             "ResourceUsage": 0.25
# CHECK-NEXT:           },
# CHECK-NEXT:           {
# CHECK-NEXT:             "InstructionIndex": 1,
# CHECK-NEXT:             "ResourceIndex": 3,
# CHECK-NEXT:             "ResourceUsage": 0.25
# CHECK-NEXT:           },
# CHECK-NEXT:           {
# CHECK-NEXT:             "InstructionIndex": 1,
# CHECK-NEXT:             "ResourceIndex": 7,
# CHECK-NEXT:             "ResourceUsage": 0.25
# CHECK-NEXT:           },
# CHECK-NEXT:           {
# CHECK-NEXT:             "InstructionIndex": 1,
# CHECK-NEXT:             "ResourceIndex": 8,
# CHECK-NEXT:             "ResourceUsage": 0.25
# CHECK-NEXT:           },
# CHECK-NEXT:           {
# CHECK-NEXT:             "InstructionIndex": 2,
# CHECK-NEXT:             "ResourceIndex": 2,
# CHECK-NEXT:             "ResourceUsage": 0.25
# CHECK-NEXT:           },
# CHECK-NEXT:           {
# CHECK-NEXT:             "InstructionIndex": 2,
# CHECK-NEXT:             "ResourceIndex": 3,
# CHECK-NEXT:             "ResourceUsage": 0.25
# CHECK-NEXT:           },
# CHECK-NEXT:           {
# CHECK-NEXT:             "InstructionIndex": 2,
# CHECK-NEXT:             "ResourceIndex": 7,
# CHECK-NEXT:             "ResourceUsage": 0.25
# CHECK-NEXT:           },
# CHECK-NEXT:           {
# CHECK-NEXT:             "InstructionIndex": 2,
# CHECK-NEXT:             "ResourceIndex": 8,
# CHECK-NEXT:             "ResourceUsage": 0.25
# CHECK-NEXT:           },
# CHECK-NEXT:           {
# CHECK-NEXT:             "InstructionIndex": 3,
# CHECK-NEXT:             "ResourceIndex": 2,
# CHECK-NEXT:             "ResourceUsage": 0.25
# CHECK-NEXT:           },
# CHECK-NEXT:           {
# CHECK-NEXT:             "InstructionIndex": 3,
# CHECK-NEXT:             "ResourceIndex": 3,
# CHECK-NEXT:             "ResourceUsage": 0.25
# CHECK-NEXT:           },
# CHECK-NEXT:           {
# CHECK-NEXT:             "InstructionIndex": 3,
# CHECK-NEXT:             "ResourceIndex": 7,
# CHECK-NEXT:             "ResourceUsage": 0.25
# CHECK-NEXT:           },
# CHECK-NEXT:           {
# CHECK-NEXT:             "InstructionIndex": 3,
# CHECK-NEXT:             "ResourceIndex": 8,
# CHECK-NEXT:             "ResourceUsage": 0.25
# CHECK-NEXT:           },
# CHECK-NEXT:           {
# CHECK-NEXT:             "InstructionIndex": 4,
# CHECK-NEXT:             "ResourceIndex": 2,
# CHECK-NEXT:             "ResourceUsage": 1
# CHECK-NEXT:           },
# CHECK-NEXT:           {
# CHECK-NEXT:             "InstructionIndex": 4,
# CHECK-NEXT:             "ResourceIndex": 3,
# CHECK-NEXT:             "ResourceUsage": 1
# CHECK-NEXT:           },
# CHECK-NEXT:           {
# CHECK-NEXT:             "InstructionIndex": 4,
# CHECK-NEXT:             "ResourceIndex": 7,
# CHECK-NEXT:             "ResourceUsage": 1
# CHECK-NEXT:           },
# CHECK-NEXT:           {
# CHECK-NEXT:             "InstructionIndex": 4,
# CHECK-NEXT:             "ResourceIndex": 8,
# CHECK-NEXT:             "ResourceUsage": 1
# CHECK-NEXT:           }
# CHECK-NEXT:         ]
# CHECK-NEXT:       }
# CHECK-NEXT:     },
# CHECK-NEXT:     {
# CHECK-NEXT:       "InstructionInfoView": {
# CHECK-NEXT:         "InstructionList": [
# CHECK-NEXT:           {
# CHECK-NEXT:             "Instruction": 0,
# CHECK-NEXT:             "Latency": 1,
# CHECK-NEXT:             "NumMicroOpcodes": 1,
# CHECK-NEXT:             "RThroughput": 0.25,
# CHECK-NEXT:             "hasUnmodeledSideEffects": false,
# CHECK-NEXT:             "mayLoad": false,
# CHECK-NEXT:             "mayStore": false
# CHECK-NEXT:           },
# CHECK-NEXT:           {
# CHECK-NEXT:             "Instruction": 1,
# CHECK-NEXT:             "Latency": 1,
# CHECK-NEXT:             "NumMicroOpcodes": 1,
# CHECK-NEXT:             "RThroughput": 0.25,
# CHECK-NEXT:             "hasUnmodeledSideEffects": false,
# CHECK-NEXT:             "mayLoad": false,
# CHECK-NEXT:             "mayStore": false
# CHECK-NEXT:           }
# CHECK-NEXT:         ]
# CHECK-NEXT:       },
# CHECK-NEXT:       "Instructions": [
# CHECK-NEXT:         "addl\t%ebx, %ebx",
# CHECK-NEXT:         "addl\t%ecx, %ecx"
# CHECK-NEXT:       ],
# CHECK-NEXT:       "Name": "bar",
# CHECK-NEXT:       "ResourcePressureView": {
# CHECK-NEXT:         "ResourcePressureInfo": [
# CHECK-NEXT:           {
# CHECK-NEXT:             "InstructionIndex": 0,
# CHECK-NEXT:             "ResourceIndex": 2,
# CHECK-NEXT:             "ResourceUsage": 0.25
# CHECK-NEXT:           },
# CHECK-NEXT:           {
# CHECK-NEXT:             "InstructionIndex": 0,
# CHECK-NEXT:             "ResourceIndex": 3,
# CHECK-NEXT:             "ResourceUsage": 0.25
# CHECK-NEXT:           },
# CHECK-NEXT:           {
# CHECK-NEXT:             "InstructionIndex": 0,
# CHECK-NEXT:             "ResourceIndex": 7,
# CHECK-NEXT:             "ResourceUsage": 0.25
# CHECK-NEXT:           },
# CHECK-NEXT:           {
# CHECK-NEXT:             "InstructionIndex": 0,
# CHECK-NEXT:             "ResourceIndex": 8,
# CHECK-NEXT:             "ResourceUsage": 0.25
# CHECK-NEXT:           },
# CHECK-NEXT:           {
# CHECK-NEXT:             "InstructionIndex": 1,
# CHECK-NEXT:             "ResourceIndex": 2,
# CHECK-NEXT:             "ResourceUsage": 0.25
# CHECK-NEXT:           },
# CHECK-NEXT:           {
# CHECK-NEXT:             "InstructionIndex": 1,
# CHECK-NEXT:             "ResourceIndex": 3,
# CHECK-NEXT:             "ResourceUsage": 0.25
# CHECK-NEXT:           },
# CHECK-NEXT:           {
# CHECK-NEXT:             "InstructionIndex": 1,
# CHECK-NEXT:             "ResourceIndex": 7,
# CHECK-NEXT:             "ResourceUsage": 0.25
# CHECK-NEXT:           },
# CHECK-NEXT:           {
# CHECK-NEXT:             "InstructionIndex": 1,
# CHECK-NEXT:             "ResourceIndex": 8,
# CHECK-NEXT:             "ResourceUsage": 0.25
# CHECK-NEXT:           },
# CHECK-NEXT:           {
# CHECK-NEXT:             "InstructionIndex": 2,
# CHECK-NEXT:             "ResourceIndex": 2,
# CHECK-NEXT:             "ResourceUsage": 0.5
# CHECK-NEXT:           },
# CHECK-NEXT:           {
# CHECK-NEXT:             "InstructionIndex": 2,
# CHECK-NEXT:             "ResourceIndex": 3,
# CHECK-NEXT:             "ResourceUsage": 0.5
# CHECK-NEXT:           },
# CHECK-NEXT:           {
# CHECK-NEXT:             "InstructionIndex": 2,
# CHECK-NEXT:             "ResourceIndex": 7,
# CHECK-NEXT:             "ResourceUsage": 0.5
# CHECK-NEXT:           },
# CHECK-NEXT:           {
# CHECK-NEXT:             "InstructionIndex": 2,
# CHECK-NEXT:             "ResourceIndex": 8,
# CHECK-NEXT:             "ResourceUsage": 0.5
# CHECK-NEXT:           }
# CHECK-NEXT:         ]
# CHECK-NEXT:       }
# CHECK-NEXT:     }
# CHECK-NEXT:   ],
# CHECK-NEXT:   "SimulationParameters": {
# CHECK-NEXT:     "-march": "x86_64",
# CHECK-NEXT:     "-mcpu": "haswell",
# CHECK-NEXT:     "-mtriple": "x86_64-unknown-unknown"
# CHECK-NEXT:   },
# CHECK-NEXT:   "TargetInfo": {
# CHECK-NEXT:     "CPUName": "haswell",
# CHECK-NEXT:     "Resources": [
# CHECK-NEXT:       "HWDivider",
# CHECK-NEXT:       "HWFPDivider",
# CHECK-NEXT:       "HWPort0",
# CHECK-NEXT:       "HWPort1",
# CHECK-NEXT:       "HWPort2",
# CHECK-NEXT:       "HWPort3",
# CHECK-NEXT:       "HWPort4",
# CHECK-NEXT:       "HWPort5",
# CHECK-NEXT:       "HWPort6",
# CHECK-NEXT:       "HWPort7"
# CHECK-NEXT:     ]
# CHECK-NEXT:   }
# CHECK-NEXT: }
